<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const user = {
        firstName: "chen",
        lastName: "jack",
        get fullName() {
          // 计算属性
          return `${this.lastName} ${this.firstName}`;
        },
        set fullName(value) {
          // 当对fullName设置的时候立即执行，并且传递设置的值
          [this.lastName, this.firstName] = value.split(" ");
        },
      };
      console.log(user.fullName);
      // 相当于对依赖属性进行设置
      // setfullName("lili zhang")
      user.fullName = "lili zhang";
      // getfullname()
      console.log(user.fullName);
    </script>
  </body>
</html>
